package org.acme.server.utils;

import java.util.Calendar;
import java.util.Date;

public class TimeUtils {

    /****
     * 获取过去sec秒的时间
     * @param sec
     * @return
     */
    public static Date getTime(int sec) {
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.SECOND, sec);
        return calendar.getTime();
    }

    /****
     * 心跳是否过期
     * @param time
     * @param sec
     * @return
     */
    public static boolean isLated(Date time, int sec) {
        return time.getTime() >= getTime(sec).getTime();
    }
}
